﻿<Window x:Class="PBS.APP.OnlineToMBTiles"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:PBS.APP.Controls"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
        Title="{DynamicResource titleOnlineToMBTiles}" Height="800" Width="800" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <StackPanel Background="SkyBlue">
                <StackPanel Margin="10,10,10,0">
                    <!--input-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{DynamicResource tbDataSourceType}" VerticalAlignment="Center" />
                        <ComboBox Grid.Column="1" ItemsSource="{Binding DataSourceTypes,Mode=OneWay}" SelectedItem="{Binding SelectedDatasourceType,Mode=TwoWay}" />
                    </Grid>
                    <!--output-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="70" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{DynamicResource tbOutputPath}" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Text="{Binding Output,Mode=TwoWay}" IsEnabled="{Binding IsIdle}" />
                        <Button Content="{DynamicResource btnBrowse}" Grid.Column="2" Command="{Binding CMDClickBrowseButton}" IsEnabled="{Binding IsIdle}" />
                        <CheckBox Grid.Column="3" Content="{DynamicResource chkboxDoCompact}" IsChecked="{Binding DoCompact,Mode=OneWayToSource}" VerticalAlignment="Center" IsEnabled="{Binding IsIdle}" ToolTipService.InitialShowDelay="50" ToolTipService.ShowDuration="15000" ToolTipService.ShowOnDisabled="True">
                            <CheckBox.ToolTip>
                                <TextBlock Text="{DynamicResource tooltipCompact}" TextWrapping="Wrap" Width="200" />
                            </CheckBox.ToolTip>
                        </CheckBox>
                    </Grid>
                    <!--name-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0" Orientation="Horizontal">
                            <TextBlock Text="{DynamicResource tbName}" VerticalAlignment="Center" />
                            <TextBlock Text="{DynamicResource tbOptionalByMBTiles}" VerticalAlignment="Center" />
                        </StackPanel>
                        <TextBox Grid.Column="1" Text="{Binding Name,Mode=TwoWay}" IsEnabled="{Binding IsIdle}" />
                    </Grid>
                    <!--description-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="140" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0" Orientation="Horizontal">
                            <TextBlock Text="{DynamicResource tbDescription}" VerticalAlignment="Center" />
                            <TextBlock Text="{DynamicResource tbOptionalByMBTiles}" VerticalAlignment="Center" />
                        </StackPanel>
                        <TextBox Grid.Column="1" Text="{Binding Description,Mode=TwoWay}" IsEnabled="{Binding IsIdle}" />
                    </Grid>
                    <!--attribution-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="140" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0" Orientation="Horizontal">
                            <TextBlock Text="{DynamicResource tbAttribution}" VerticalAlignment="Center" />
                            <TextBlock Text="{DynamicResource tbOptionalByMBTiles}" VerticalAlignment="Center" />
                        </StackPanel>
                        <TextBox Grid.Column="1" Text="{Binding Attribution,Mode=TwoWay}" IsEnabled="{Binding IsIdle}" />
                    </Grid>
                    <Button Margin="0,5,0,5" Width="100" Content="{DynamicResource btnStart}" Command="{Binding CMDClickStartButton}" />
                </StackPanel>
            </StackPanel>
            <!--progress-->
            <controls:ConvertingStatus x:Name="convertingStatus1" />            
        </StackPanel>
        <!--map-->
        <Grid Grid.Row="1">
            <esri:Map x:Name="map1" WrapAround="True" SnapToLevels="True">
                <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            </esri:Map>
            <!--map property element-->
            <StackPanel>
                <!--download extent and tiles count-->
                <Grid Background="SkyBlue">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="2*" />
                        <ColumnDefinition Width="1*" />
                    </Grid.ColumnDefinitions>
                    <!--download extent-->
                    <StackPanel Grid.Column="0" Orientation="Horizontal">
                        <TextBlock Text="{DynamicResource tbDownloadExtent}" />
                        <ComboBox SelectedIndex="{Binding SelectedIndexOfDrawExtentMethod,Mode=TwoWay}" Width="145" IsEnabled="{Binding IsIdle}">
                            <ComboBoxItem Content="{DynamicResource tbDrawExtentByMouse}" />
                            <ComboBoxItem Content="{DynamicResource tbDrawByImportSHP}" />
                        </ComboBox>
                        <TextBlock>
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}XMin:{0:N3},YMin:{1:N3},XMax:{2:N3},YMax:{3:N3}" Mode="OneWay">
                            <Binding Path="DownloadExtent.XMin" />
                            <Binding Path="DownloadExtent.YMin" />
                            <Binding Path="DownloadExtent.XMax" />
                            <Binding Path="DownloadExtent.YMax" />
                        </MultiBinding>
                        </TextBlock.Text>
                        </TextBlock>
                    </StackPanel>
                    <!--tiles count-->
                    <StackPanel Grid.Column="1" Orientation="Horizontal">
                        <TextBlock Text="{DynamicResource tbTilesCount}" />
                        <TextBlock Text="{Binding TilesCount,StringFormat={}{0:N0}}" />
                    </StackPanel>
                </Grid>
                <!--download levels-->
                <controls:DownloadLevels x:Name="ctrlDownloadLevels" Levels="{Binding Levels,Mode=TwoWay}" IsEnabled="{Binding IsIdle}" Background="SkyBlue" />
                <!--profiles-->
                <StackPanel Orientation="Horizontal" Background="SkyBlue">
                    <TextBlock Text="{DynamicResource tbDownloadProfiles}" VerticalAlignment="Center"/>
                    <ComboBox Width="200" IsEditable="True" ItemsSource="{Binding Profiles,Mode=OneWay}" Text="{Binding SelectedProfile,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsIdle}" />
                    <Button Content="{DynamicResource btnSave}" Command="{Binding CMDClickProfileButton}" CommandParameter="SAVE" Margin="0,0,10,0" IsEnabled="{Binding IsIdle}" />
                    <Button Content="{DynamicResource btnLoad}" Command="{Binding CMDClickProfileButton}" CommandParameter="LOAD" Margin="0,0,10,0" IsEnabled="{Binding IsIdle}" />
                    <Button Content="{DynamicResource btnDelete}" Command="{Binding CMDClickProfileButton}" CommandParameter="DELETE" IsEnabled="{Binding IsIdle}" />
                </StackPanel>
                <Grid>
                    <!--level textblock-->
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{DynamicResource tbLevel}" Background="AliceBlue" FontSize="17"/>
                        <TextBlock Text=":"  Background="AliceBlue" FontSize="17"/>
                        <TextBlock Text="{Binding CurrentLevel,Mode=OneWay}" Background="AliceBlue" FontSize="17"/>
                    </StackPanel>
                    <!--tip-->
                    <TextBlock HorizontalAlignment="Center" Text="{DynamicResource tbDrawTip}" FontSize="22" Background="PaleTurquoise" Visibility="{Binding IsDrawExtentTipVisible}" Foreground="Red" FontFamily="Microsoft YaHei" />
                </Grid>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
